import require from '../utils/require'

export function getFriendList(userId: number, searchContent: string | null) {
  if (searchContent) {
    return require.get('/friend/getFriendList', {
      userId: userId,
      searchContent: searchContent
    })
  } else {
    return require.get('/friend/getFriendList', {
      userId: userId
    })
  }
}

export function getFriendApplyList(userId: number) {
  return require.get('/friend/getFriendApplyList', {
    userId: userId
  })
}

export function queryFriendView(userId: number | undefined) {
  return require.get('/friend/queryFriendView', {
    userId: userId
  })
}

export function searchFriend(account: string, userId: number) {
  const params = {
    account: account,
    userId: userId
  }

  return require.get('/friend/searchFriend', params)
}

export function checkIsFriend(userId: number, targetId: number) {
  const params = {
    userId: userId,
    targetId: targetId
  }

  return require.get('/friend/checkIsFriend', params)
}

export function deleteFriend(userId: number, targetId: number) {
  const params = {
    userId: userId,
    targetId: targetId
  }

  return require.delete('/friend/deleteFriend', params)
}
